<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>my模板引擎</title>
</head>
<body>
  
  <div id="app">

  </div>

  <script src="./template.js"></script>
  <script type="text/html" id="tpl-user">
    <div>姓名: {{ name }}</div>
    <div>年龄: {{ age }}</div>
    <div>性别: {{ gender }}</div>
    <div>住址: {{ address }}</div>
  </script>
  <script type="text/javascript">
    var data = {
      name: "张三",
      age: "18",
      gender: "男",
      address: "中国宇宙村"
    }

    var myTpl = template("tpl-user", data);
    document.getElementById("app").innerHTML = myTpl;
  </script>
</body>
</html>